home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Function_G2082879112007.psc / Grapher v1 / Form1.frm < prev   
Text File  |  2007-09-10  |  16KB  |  558 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC}#1.0#0"; "msscript.ocx"
  4. Begin VB.Form Form1 
  5.    Caption         =   "Grapher v1.0"
  6.    ClientHeight    =   8700
  7.    ClientLeft      =   165
  8.    ClientTop       =   795
  9.    ClientWidth     =   15240
  10.    Icon            =   "Form1.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   8700
  13.    ScaleWidth      =   15240
  14.    StartUpPosition =   3  'Windows Default
  15.    WindowState     =   2  'Maximized
  16.    Begin VB.CommandButton Command4 
  17.       Caption         =   "SAVE GRAPH "
  18.       Height          =   495
  19.       Left            =   6240
  20.       TabIndex        =   28
  21.       Top             =   9480
  22.       Width           =   1575
  23.    End
  24.    Begin MSComctlLib.ProgressBar PB 
  25.       Height          =   255
  26.       Left            =   120
  27.       TabIndex        =   23
  28.       Top             =   120
  29.       Width           =   15135
  30.       _ExtentX        =   26696
  31.       _ExtentY        =   450
  32.       _Version        =   393216
  33.       Appearance      =   0
  34.       Scrolling       =   1
  35.    End
  36.    Begin VB.CommandButton Command3 
  37.       Caption         =   "PLOT !"
  38.       Height          =   495
  39.       Left            =   6240
  40.       TabIndex        =   22
  41.       Top             =   8880
  42.       Width           =   1575
  43.    End
  44.    Begin VB.ListBox roots 
  45.       Height          =   1815
  46.       Left            =   12840
  47.       TabIndex        =   20
  48.       Top             =   7920
  49.       Width           =   2415
  50.    End
  51.    Begin VB.TextBox steps 
  52.       CausesValidation=   0   'False
  53.       Height          =   285
  54.       Left            =   2160
  55.       TabIndex        =   15
  56.       Text            =   "400"
  57.       Top             =   8760
  58.       Width           =   2055
  59.    End
  60.    Begin VB.CheckBox autoy 
  61.       Caption         =   "AUTO Y ?"
  62.       Height          =   255
  63.       Left            =   4320
  64.       TabIndex        =   13
  65.       Top             =   8400
  66.       Value           =   1  'Checked
  67.       Width           =   1935
  68.    End
  69.    Begin MSScriptControlCtl.ScriptControl tmpScript 
  70.       Left            =   8400
  71.       Top             =   9480
  72.       _ExtentX        =   1005
  73.       _ExtentY        =   1005
  74.    End
  75.    Begin MSScriptControlCtl.ScriptControl vbscript 
  76.       Left            =   9000
  77.       Top             =   9480
  78.       _ExtentX        =   1005
  79.       _ExtentY        =   1005
  80.    End
  81.    Begin VB.ComboBox txtfunc 
  82.       BackColor       =   &H00FFFFFF&
  83.       Height          =   315
  84.       Left            =   2160
  85.       TabIndex        =   12
  86.       Text            =   "3*SIN(X)*COS(2*X)"
  87.       Top             =   7560
  88.       Width           =   5655
  89.    End
  90.    Begin VB.CheckBox Check1 
  91.       Caption         =   "DISPLAY DERIVATIVE?"
  92.       Height          =   615
  93.       Left            =   6360
  94.       TabIndex        =   11
  95.       Top             =   8040
  96.       Width           =   1455
  97.    End
  98.    Begin VB.CommandButton Command2 
  99.       Caption         =   "ZOOM -"
  100.       Height          =   255
  101.       Left            =   5280
  102.       TabIndex        =   7
  103.       Top             =   8040
  104.       Width           =   975
  105.    End
  106.    Begin VB.CommandButton Command1 
  107.       Caption         =   "ZOOM +"
  108.       Height          =   255
  109.       Left            =   4320
  110.       TabIndex        =   6
  111.       Top             =   8040
  112.       Width           =   855
  113.    End
  114.    Begin VB.TextBox ymx 
  115.       Height          =   285
  116.       Left            =   3240
  117.       TabIndex        =   5
  118.       Text            =   "20"
  119.       Top             =   8400
  120.       Width           =   975
  121.    End
  122.    Begin VB.TextBox ymn 
  123.       Height          =   285
  124.       Left            =   2160
  125.       TabIndex        =   4
  126.       Text            =   "-20"
  127.       Top             =   8400
  128.       Width           =   975
  129.    End
  130.    Begin VB.TextBox xmx 
  131.       Height          =   285
  132.       Left            =   3240
  133.       TabIndex        =   3
  134.       Text            =   "10"
  135.       Top             =   8040
  136.       Width           =   975
  137.    End
  138.    Begin VB.TextBox xmn 
  139.       Height          =   285
  140.       Left            =   2160
  141.       TabIndex        =   2
  142.       Text            =   "-10"
  143.       Top             =   8040
  144.       Width           =   975
  145.    End
  146.    Begin MSComctlLib.StatusBar StatusBar1 
  147.       Align           =   2  'Align Bottom
  148.       Height          =   375
  149.       Left            =   0
  150.       TabIndex        =   1
  151.       Top             =   8325
  152.       Width           =   15240
  153.       _ExtentX        =   26882
  154.       _ExtentY        =   661
  155.       Style           =   1
  156.       _Version        =   393216
  157.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  158.          NumPanels       =   1
  159.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  160.          EndProperty
  161.       EndProperty
  162.    End
  163.    Begin VB.PictureBox display 
  164.       AutoRedraw      =   -1  'True
  165.       BackColor       =   &H00FFFFFF&
  166.       FillColor       =   &H00C0C0C0&
  167.       ForeColor       =   &H00E0E0E0&
  168.       Height          =   6975
  169.       Left            =   120
  170.       MousePointer    =   2  'Cross
  171.       ScaleHeight     =   6915
  172.       ScaleWidth      =   15075
  173.       TabIndex        =   0
  174.       Top             =   360
  175.       Width           =   15135
  176.    End
  177.    Begin VB.Label f_inf 
  178.       Caption         =   "0"
  179.       Height          =   255
  180.       Left            =   8160
  181.       TabIndex        =   27
  182.       Top             =   7920
  183.       Width           =   4095
  184.    End
  185.    Begin VB.Label mouse_inf 
  186.       Caption         =   "0"
  187.       Height          =   255
  188.       Left            =   8160
  189.       TabIndex        =   26
  190.       Top             =   7560
  191.       Width           =   4095
  192.    End
  193.    Begin VB.Label ye 
  194.       Caption         =   "Label8"
  195.       Height          =   255
  196.       Left            =   9360
  197.       TabIndex        =   25
  198.       Top             =   9600
  199.       Visible         =   0   'False
  200.       Width           =   855
  201.    End
  202.    Begin VB.Label xe 
  203.       Caption         =   "Label7"
  204.       Height          =   255
  205.       Left            =   8040
  206.       TabIndex        =   24
  207.       Top             =   9600
  208.       Visible         =   0   'False
  209.       Width           =   975
  210.    End
  211.    Begin VB.Label RO 
  212.       Alignment       =   2  'Center
  213.       Caption         =   "ROOTS:"
  214.       Height          =   255
  215.       Left            =   12840
  216.       TabIndex        =   21
  217.       Top             =   7560
  218.       Width           =   2415
  219.    End
  220.    Begin VB.Label ymaxval 
  221.       Caption         =   "0"
  222.       Height          =   255
  223.       Left            =   2160
  224.       TabIndex        =   19
  225.       Top             =   9240
  226.       Width           =   3855
  227.    End
  228.    Begin VB.Label yminval 
  229.       Caption         =   "0"
  230.       Height          =   255
  231.       Left            =   2160
  232.       TabIndex        =   18
  233.       Top             =   9600
  234.       Width           =   3855
  235.    End
  236.    Begin VB.Label Label6 
  237.       Caption         =   "Function's Max Value :"
  238.       Height          =   255
  239.       Left            =   120
  240.       TabIndex        =   17
  241.       Top             =   9240
  242.       Width           =   1935
  243.    End
  244.    Begin VB.Label Label5 
  245.       Caption         =   "Function's Min Value :"
  246.       Height          =   255
  247.       Left            =   120
  248.       TabIndex        =   16
  249.       Top             =   9600
  250.       Width           =   1935
  251.    End
  252.    Begin VB.Label Label4 
  253.       Caption         =   "STEPS :"
  254.       Height          =   255
  255.       Left            =   120
  256.       TabIndex        =   14
  257.       Top             =   8760
  258.       Width           =   1935
  259.    End
  260.    Begin VB.Label Label3 
  261.       Caption         =   "Ymin , Ymax VALUES :"
  262.       Height          =   255
  263.       Left            =   120
  264.       TabIndex        =   10
  265.       Top             =   8400
  266.       Width           =   1935
  267.    End
  268.    Begin VB.Label Label2 
  269.       Caption         =   "Xmin , Xmax VALUES :"
  270.       Height          =   255
  271.       Left            =   120
  272.       TabIndex        =   9
  273.       Top             =   8040
  274.       Width           =   1935
  275.    End
  276.    Begin VB.Label Label1 
  277.       Caption         =   "DISPLAY FUNCTION :"
  278.       Height          =   255
  279.       Left            =   120
  280.       TabIndex        =   8
  281.       Top             =   7560
  282.       Width           =   1935
  283.    End
  284.    Begin VB.Menu ext 
  285.       Caption         =   "Exit.."
  286.    End
  287.    Begin VB.Menu abt 
  288.       Caption         =   "About.."
  289.    End
  290. End
  291. Attribute VB_Name = "Form1"
  292. Attribute VB_GlobalNameSpace = False
  293. Attribute VB_Creatable = False
  294. Attribute VB_PredeclaredId = True
  295. Attribute VB_Exposed = False
  296. Dim mousex As Double
  297. Dim mousey As Double
  298. Dim yymax As Double
  299. Dim yymin As Double
  300. Option Explicit
  301.  
  302. Private Sub Combo1_Change()
  303.  
  304. End Sub
  305.  
  306. Private Sub Command1_Click()
  307. Const factor = 0.1
  308. Dim min As Double
  309. Dim max As Double
  310. Dim dx As Double
  311. min = xmn
  312. max = xmx
  313. dx = max - min
  314. xmn = Round(min + factor * dx, 4)
  315. xmx = Round(max - factor * dx, 4)
  316.  
  317. vbscript.Reset
  318. vbscript.AddCode "Function f(x)" & vbCrLf & "f=" & txtfunc.Text & vbCrLf & "End Function"
  319. plot xmn, xmx, ymn, ymx, steps
  320. End Sub
  321.  
  322. Private Sub Command2_Click()
  323. Const factor = 0.1
  324. Dim min As Double
  325. Dim max As Double
  326. Dim dx As Double
  327. min = xmn
  328. max = xmx
  329. dx = max - min
  330. xmn = Round(min - factor * dx, 4)
  331. xmx = Round(max + factor * dx, 4)
  332.  
  333. vbscript.Reset
  334. vbscript.AddCode "Function f(x)" & vbCrLf & "f=" & txtfunc.Text & vbCrLf & "End Function"
  335. plot xmn, xmx, ymn, ymx, steps
  336. End Sub
  337.  
  338. Private Sub Command3_Click()
  339. vbscript.Reset
  340. vbscript.AddCode "Function f(x)" & vbCrLf & "f=" & txtfunc.Text & vbCrLf & "End Function"
  341. txtfunc.AddItem (txtfunc)
  342. plot xmn, xmx, ymn, ymx, steps
  343. End Sub
  344.  
  345. Private Sub Command4_Click()
  346. Dim path As String
  347. path = App.path + "\LastGraph" + Str(Timer) + ".bmp"
  348. SavePicture display.Image, path
  349. End Sub
  350.  
  351. Private Sub display_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  352. mousex = XDISPLAY(X, 0, display.Width, xmn, xmx)
  353. xe = Round(mousex, 4)
  354. mousey = YDISPLAY(Y, 0, display.Height, yymax, yymin)
  355. 'mousey = vbscript.Eval("f(" + Str(xe) + ")")
  356. ye = Round(mousey, 4)
  357. mouse_inf = "Mouse Pos (x,y) : ( " + xe + " , " + ye + " )"
  358.  
  359. mousey = vbscript.Eval("f(" + Str(xe) + ")")
  360. ye = Round(mousey, 4)
  361. f_inf = "F( " + xe + " ) = " + ye
  362.  
  363. End Sub
  364.  
  365. Private Sub Form_Load()
  366. Form1.Show
  367. display.ScaleWidth = display.Width
  368. display.ScaleHeight = display.Height
  369.  
  370. vbscript.Reset
  371. vbscript.AddCode "Function f(x)" & vbCrLf & "f=" & txtfunc.Text & vbCrLf & "End Function"
  372. txtfunc.AddItem (txtfunc)
  373. plot xmn, xmx, ymn, ymx, steps
  374. 'a = YDISPLAY(-8, 1, -5, -2, 5)
  375.  
  376. End Sub
  377. Function XDISPLAY(ByVal x1 As Double, xs1 As Double, xe1 As Double, xs2 As Double, xe2 As Double) As Double
  378. 'normal display, sign(xe1-xs1)=sign(xe2-xs2)
  379. 'xs1----x1------------xe1
  380. 'TO
  381. 'xs2--------XDISPLAY-------------xe2
  382.  
  383. XDISPLAY = (x1 - xs1) * ((xe2 - xs2) / (xe1 - xs1)) + xs2
  384. End Function
  385. Function YDISPLAY(ByVal y1 As Double, ys1 As Double, ye1 As Double, ys2 As Double, ye2 As Double) As Double
  386. On Error GoTo er
  387. 'inverse display, sign(ye1-ys1)=-sign(ye2-ys2)
  388. YDISPLAY = (y1 - ys1) * ((ye2 - ys2) / (ye1 - ys1)) + ys2
  389. er:
  390. End Function
  391. Sub BULD_DISPLAY(xmin As Double, xmax As Double, ymin As Double, ymax As Double)
  392. 'On Error Resume Next
  393. Const dxsize = 800
  394. Const dysize = 800
  395. Const digits = 2
  396. Dim xaxis As Long
  397. Dim yaxis As Long
  398. Dim col As Long
  399. Dim k As Integer
  400. display.Cls
  401. col = display.ForeColor
  402.  
  403. 'get y-axis position
  404. yaxis = XDISPLAY(0, xmin, xmax, 0, display.Width)
  405. 'get x-axis position
  406. xaxis = YDISPLAY(0, ymax, ymin, 0, display.Height)
  407.  
  408. 'BUILD X-AXES!
  409. If xaxis >= 0 And xaxis <= display.Height Then
  410. 'up
  411.     For k = 0 To Int(xaxis / dxsize)
  412.         display.Line (0, xaxis - k * dxsize)-(display.Width, xaxis - k * dxsize)
  413.     Next
  414. 'down
  415.     For k = 1 To Int((display.Height - xaxis) / dxsize)
  416.         display.Line (0, xaxis + k * dxsize)-(display.Width, xaxis + k * dxsize)
  417.     Next
  418. Else
  419.     For k = 0 To Int(display.Height / dxsize)
  420.         display.Line (0, k * dxsize)-(display.Width, k * dxsize)
  421.     Next
  422. End If
  423.  
  424. 'BUILD Y-AXES!
  425. If yaxis >= 0 And yaxis <= display.Width Then
  426.     'left
  427.     For k = 0 To Int(yaxis / dysize)
  428.         display.Line (yaxis - k * dysize, 0)-(yaxis - k * dysize, display.Height)
  429.     Next
  430.     'right
  431.     For k = 1 To Int((display.Width - yaxis) / dysize)
  432.         display.Line (yaxis !Y-------------xe2
  433.  
  434. XDISPLAYBy6UZsplay.Line (0, k * dxsize)-(display.Wi96Dr
  435. 'get y-axis position
  436. yaxis = XDISPLAY(0, xmin, xmax, 0, display.Width)
  437. 'get u-LAddCLinAes) / dysize)
  438.         displayY-AXES!
  439. If yaxis >= 0 And yaxis <in(x1 - xs1) *!
  440.      0)-(yaxxs.YsHi
  441. D
  442. D
  443. D
  444. D
  445. D
  446. D
  447. 3('ye Sub display_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  448. mousex = XDISPLAY(X, 0, di ys2
  449. er:
  450. End Funcon 
  451. YDISPLAY egin a , path
  452. End Sub
  453.  
  454. Private Sub display_Mgin a , path
  455. End Sub
  456.  
  457. Private Sfik *   End
  458.    Begin VB.Label Label5
  459.  sousey As Double
  460. Di 12
  461. Private pfx      disSPLAY(X,stT hift As SPLAY(X, 0, di ys2
  462. er:
  463. End Funcon 
  464. YDP      =  (0,et2 sex Acon 
  465. 4l  For kCEnd Sub
  466.  
  467. Private Sub display_Mgin a , path
  468. End Sub
  469.  
  470. Private Sfik * + Begin VB.Lr1Sfiyuxe2<=+ (0, k * dxsize)-(display.Wi96Dr
  471. 'gE,O Eseger, X As Single, Y As Sinl- End
  472.    Beg8eeg8eeg8eeg8eeg8eeg8eeg8eeg8esc>wC, di ys2
  473. er:
  474. End Funcon 
  475. YDISPLAY egin a , path
  476. End Sub
  477.  
  478. Private Sub display_Mgin a , path
  479. End Sub
  480.  
  481. Privat
  482. Di 12
  483. Private pfx      disSPLAY(X,stT hift As SPLAY(X, 0, di y    display.Line (0, xaxis + k *1i6Dr
  484. 'get y-axis position
  485. yasPLAY(X, 0, di ys2
  486. er:
  487. End Funcon 
  488. YDP      =  (0,et2 sex Acon 
  489. 4l  For kCEnd Sub
  490.          Btralse, Y As per:
  491. End Ffme=on
  492. y-AXES!
  493. If xaxis >0n ( Ffme=on
  494. y-AXES!
  495. If xaxis >fme=on
  496. xaxis >0 n   =   "0"
  497.       Height   As p_(1tion
  498. yasPX, k * ion
  499. yasP., k * ion
  500. yasP., k * ion
  501. F  =   8040
  502.       Width         i=m, X As            i=m, X As            i=m, X=m, X AseyYsHi
  503. D
  504. D
  505. D
  506. 1oEn ( Ffme=on,stT hift As SPLAY(X, 0, di y    display.Line (0, xaxis + k *1i6Dr
  507. 'get y-axis positiof.le53ght Then
  508. 'up
  509.     For k = =on,stT hift As SPLAY(X, 0, di ieY5S   i=m, XFor k = =on,stT hift As SPLAY(
  510. e1kCEnd Sub
  511.     r             =     He As SPLAY(X, 0, di y0
  512.   *1i6D_ .tis + k *1ie, 0)-(yrLAY(X, 0, di  0, di ys2
  513. er:
  514. 1DRlPLAY(X, 0, di y0
  515.   *1i6D_ .tMfr,sttis +>
  516. mtOIa1i6D_ .tMfr,sttis +>
  517. mtOIa1i6D_'e(0, xaxlMnd(mousey, 4)
  518. f_in
  519. F  =   8040
  520.       Width  r=Pri'{E'9r7B  1yLLAYr7B  1yLLAYr7B  1yLLAYr7B  1yLLAYr7B  1yLLAYr7B  1yLLAYr7B  1yLLAYX, 0,
  521. a omn
  522. max = xmx
  523. dx b=2  8021yLLAYax-B  1yLLAYr7B  e'ye Su.r1yLLAYrO-B   Ec(8x b=2  80"XB  1yLLAYX,A1i6D_'e(yLLAx  8021yLrl:i80"XB  1yLLAYX,Ayt Then
  524. 'up
  525.     For k = =on,stT tis + E,stT tis + E,stT tis + E,stT t-f=9x>'  = 80fP Doxm'okx, 0,
  526. a omn
  527. max = xor k = =Iaor
  528. xnis positisy8 ILLA =   8040
  529.       Width  r=Pri'{E4sitisy8 ILLA =a oTG   Width  For k = =on,stT tis + E,stT tis + E,stT tis + E,stT t-f=9x>'  = 80fP Doxm'okx, 0,
  530. a omn
  531. max = xor k = =Iaor
  532. xnie(yLLLLA =   8040
  533. pmhen"n
  534. max = xor k = =IaorpSstT tie k = x = xor  Width  r=Pri'{E4sitisy8 ILLA =a oTG   Width  For k = =on,stT tin      F For tis   xor  Widt-isy8 ILLA  tis   xor  Widt-is th - yaxis) tplMnd(mousey, 4)
  535. f_in
  536. F  =   80oB(0, xaxlMnd(mousey, 4)
  537. f_in
  538. -B   Esn
  539. i- ya<     3 d(mousey, 4)
  540. f_in
  541. -B   Esn
  542. i- y>A(t2 5unc.AddIteE}hmsl=9x>' 5unc.AddIteE}hmsl=9x>' 5unc.AdBvpnie(yLLLLA =  d(mousey, 4)
  543. f_in
  544. -B 7l0s,r
  545. xnie(yLLLLA =   80rxaxlMn   "Xmin , Xmax VALUES :"
  546.       (mousey, 4)
  547. f_in
  548. -B 
  549. YDP      =Y,sey, 4
  550.       (mousey, 4)
  551. f_in
  552. -B 
  553. YDP l0oB(0, xaxlMnd(mousey, 4)
  554. f_in
  555. F{kA5 _in
  556. -B   EsnTye1 -BTb
  557.  
  558. PrV